#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5505;

int n, m;
int cnt;
int row[N], col[N];
int l[N], r[N], u[N], d[N];
int h[505], s[505];  // 每行的头节点 每列的节点数目
int ans[N];
void init() {
  rep(i, 0, m) u[i] = d[i] = i, l[i] = i - 1, r[i] = i + 1;
  l[0] = m, r[m] = 0;
  cnt = m;
}
void link(int x, int y) {
  ++cnt, s[y]++;
  row[cnt] = x, col[cnt] = y;
  // 插入到列链表中
  d[u[y]] = cnt;
  u[cnt] = u[y];
  u[y] = cnt;
  d[cnt] = y;
  // 插入到行链表中
  if (!h[x]) {
    h[x] = l[cnt] = r[cnt] = cnt;
  } else {
    r[l[h[x]]] = cnt;
    l[cnt] = l[h[x]];
    l[h[x]] = cnt;
    r[cnt] = h[x];
  }
}
void remove(int y) {
  r[l[y]] = r[y];
  l[r[y]] = l[y];
  for (int i = d[y]; i != y; i = d[i]) {
    for (int j = r[i]; j != i; j = r[j]) {
      d[u[j]] = d[j];
      u[d[j]] = u[j];
      s[col[j]]--;
    }
  }
}
void resume(int y) {
  r[l[y]] = y;
  l[r[y]] = y;
  for (int i = d[y]; i != y; i = d[i]) {
    for (int j = r[i]; j != i; j = r[j]) {
      d[u[j]] = j;
      u[d[j]] = j;
      s[col[j]]++;
    }
  }
}
bool dance(int dep) {
  if (!r[0]) {
    rep(i, 1, dep) cout << ans[i] << ' ';
    return true;
  }
  // 找最少列
  int y = r[0];
  for (int j = r[0]; j; j = r[j])
    if (s[j] < s[y]) y = j;
  remove(y);
  for (int i = d[y]; i != y; i = d[i]) {
    ans[dep + 1] = row[i];
    for (int j = r[i]; j != i; j = r[j]) remove(col[j]);
    if (dance(dep + 1)) return true;
    // 注意正确的还原顺序
    for (int j = l[i]; j != i; j = l[j]) resume(col[j]);
  }
  resume(y);
  return false;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  init();
  rep(i, 1, n) rep(j, 1, m) {
    int x;
    cin >> x;
    if (x) link(i, j);
  }
  if (!dance(0)) cout << "No Solution!";
  return 0;
}